# The user needs to assign these for their project
CCFILESR=receiver.cc
CCFILESS=sender.cc
EXECR=receiver
EXECS=sender
EXECSHIVR=shivarec
EXECSHIVS=shivasen

# The included dependency file contains all the incremental compilation info,
# however we use the implicit rule for making each one which is (simplified):
# g++ $(CXXFLAGS) -c -o Foo.o Foo.cc
# Thus we place our compiler flags into this default variable
CXXFLAGS=-Wall -g
# Create all the needed .o file names from the .cc files
OFILESR=$(CCFILESR:.cc=.o)
OFILESS=$(CCFILESS:.cc=.o)
# The main linking rule
$(EXECR): $(OFILESR)
	g++ -o $(EXECR) $(OFILESR) -lpthread
$(EXECS): $(OFILESS)
	g++ -o $(EXECS) $(OFILESS) -lpthread
$(EXECSHIVR): $(OFILESR)
	g++ -o $(EXECSHIVR) $(OFILESR) -lpthread -lnsl -lsocket -lrt
$(EXECSHIVS) : $(OFILESS) 
	g++ -o $(EXECSHIVS) $(OFILESS) -lpthread -lnsl -lsocket -lrt

	
# Clean not only cleans up object files, but also recreates the dependency file
clean:
	rm -f *~
	rm -f *.o
	rm -f $(EXECR)
	rm -f $(EXECS)
	rm -f $(EXECSHIVR)
	rm -f $(EXECSHIVS)
	g++ $(CCFILESR) -MM > $(EXECR).d
	g++ $(CCFILESS) -MM > $(EXECS).d
# Always include the dependency file unless we run the clean command,
# which will make it even if it does not exist
ifneq ($(MAKECMDGOALS), clean)
include $(EXECR).d
include $(EXECS).d
endif
